package com;



import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import connection.DBConnection;

/**
 * Servlet implementation class GeneralDeleteServlet
 */
@WebServlet("/GeneralDeleteServlet")
public class GeneralDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GeneralDeleteServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	
		PrintWriter out = response.getWriter();
		String languages = "",mst="";
		String lang[]=request.getParameterValues("voucher1");
		String ms[]=request.getParameterValues("voucher2");
		String updatecust="",updatemaster="";

int j=0,k=0,l=0;
		DBConnection dbc=new DBConnection();	
		 Connection con=dbc.getNewConnection();
		 
		 Statement st = null;
		 ResultSet rs = null;
		 String r1=""; 
	
		 
		 try 
			{
				st = con.createStatement();
				
				for(int i=0;i<lang.length;i++){
				    languages=lang[i];
				   
				     updatecust = "delete from generalquick where gcode ='"+languages+"';";
				     j=st.executeUpdate(updatecust);
					
				    }
				
				
		
				if(j>0){
					 RequestDispatcher requestDispatcher; 
				        requestDispatcher = request.getRequestDispatcher("QuickFunction.jsp" ) ;
				        requestDispatcher.forward(request,response);
					}
					else
		               out.print("Sorry..!! Got an exception.");
				
			}
			catch (SQLException e) 
			{
				e.printStackTrace();
			}
			
	
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
